import React from "react";
import "./App.css";
import axios from "axios";
import ListItem from "./components/listItem";
import { DropdownMenu, Search } from "react-vant";
class App extends React.Component {
  state = {
    list: [],
    text: "",
    html: "<b>1231</b>",
  };
  getList = async (q) => {
    const res = await axios.get("/api/list", { params: { q } });
    this.setState({ list: res.data.data });
  };
  onSearch(value) {
    this.getList(value);
    this.setState({
      text: value,
    });
  }
  render() {
    const { show, list, option, text, html } = this.state;
    return (
      <div>
        <Search
          placeholder="请输入内容"
          onSearch={(value) => this.onSearch(value)}
        ></Search>
        {/* 列表 */}
        {list.map((v) => {
          return <ListItem text={text} key={v.id} v={v}></ListItem>;
        })}
      </div>
    );
  }
  componentDidMount() {
    // 请求数据
    this.getList();
  }
}

export default App;
